<%@ page import="id.co.gomobile.assessment.Item" %>
<%@page import="id.co.gomobile.assessment.ItemOption"%>
<html>
    <head>
        <meta http-equiv="Content-Type" content="text/html; charset=UTF-8" />
        <meta name="layout" content="main" />
        <title>Edit Option</title>
    </head>
    <body>
    <g:render template="/shared/navigation" />
    
    <div id="body">
    
    <h1>Edit Option</h1>

    <g:if test="${flash.message}">
        <div class="message">${flash.message}</div>
    </g:if>

    <g:hasErrors bean="${itemOptionInstance}">
    <div class="errors">
        <g:renderErrors bean="${itemOptionInstance}" as="list" />
    </div>
    <br/>
    </g:hasErrors>

    <g:form action="update" method="post" >
        <g:hiddenField name="id" value="${itemOptionInstance?.id}" />
        <g:hiddenField name="version" value="${itemOptionInstance?.version}" />

    <div class="form">

    <fieldset>        
        <h3>Option Details</h3>
        
        <br/>

        <label for="item" class="required ${hasErrors(bean: itemOptionInstance, field: 'item', 'errors')}">Item :</label>
        <div class="value">
            <g:select name="item.id" from="${Item.findAllById(itemOptionInstance?.item?.id)}" optionKey="id" optionValue="text" value="${itemOptionInstance?.item?.id}" disabled="true" />
            <g:hiddenField name="item.id" value="${itemOptionInstance?.item?.id}" />
        </div>

        <br/>
    
        <label for="name" class="required ${hasErrors(bean: itemOptionInstance, field: 'text', 'errors')}">Text :</label>
        <div class="value">
            <g:textArea name="text" value="${itemOptionInstance?.text}" />
        </div>
                
        <br/>

        <label for="correct" class="${hasErrors(bean: itemOptionInstance, field: 'correct', 'errors')}">Is Correct? :</label>
        <div class="value">
            <g:checkBox name="correct" value="${itemOptionInstance?.correct}" />
        </div>

        <br/>
        <br/>

        <div class="buttons">
            <span class="button"><g:submitButton name="update" class="save" value="${message(code: 'default.button.create.label', default: 'Update')}" /></span>
        </div>
    </fieldset>

    </div>
    </g:form>
    
    </div>
    </body>
</html>